<?php
/*------------------------------------------------------ */
//-- 腾讯云短信接口
//-- @author iqgmy
/*------------------------------------------------------ */
namespace sms;
$i = (isset($modules)) ? count($modules) : 0;
$modules[$i]["name"] = "腾讯短信";
$modules[$i]["val"] = array('appid'=>'appId','appkey'=>'appKey','sign'=>'签名');

use Qcloud\Sms\SmsSingleSender;
class Tenxun
{
    protected $appId;
    protected $appkey;
    protected $sign;
    public function __construct($val){
        $this->appId    = $val['appid'];
        $this->appkey = $val['appkey'];
        $this->sign = $val['sign'];
    }
    /**
     * 短信发送示例
     *
     * @mobile  短信发送对象手机号码
     * @tplCode  短信发送场景，会自动传入短信模板ID
     * @smsParams   短信内容数组
     */
    public function send($mobile, $tplCode, $smsParams)
    {
        $ssender = new SmsSingleSender($this->appId, $this->appkey);

        $result = $ssender->sendWithParam("86", $mobile,$tplCode, [$smsParams['code']], $this->sign);
        if(empty($result['Response']['Error']) == false){
            return result['Response']['Error']['Message'];
        }
        return true;
    }


}